﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using System.Reflection;
using DevExpress.Skins;
using DevExpress.XtraBars.Ribbon;
using DevExpress.Utils.Drawing;
using DevExpress.Utils;
using TierService;


namespace CodePortal
{
    public partial class frmShopping : DevExpress.XtraBars.Ribbon.RibbonForm
    {
        private static Boolean IsRibonBarHide = false;

        private string DLL_CodePortal = "CodePortal";
        private string DLL_BasisMgr = "BasisMgr";
        private string DLL_OrderMgr = "OrderMgr";


        public frmShopping()
        {
            InitializeComponent();
            InitSkinGallery();
            //判断Menu权限
            CheckMenuPrivage();
            this.Text = "上海磊盛医疗器械有限公司进销存管理系统";
        }

        private void CheckMenuPrivage()
        {
            if (TierService.Utility.gUserID == "admin") return;

            DataSet ds = TierService.Utility.GetRoleFuncs();

            BarManagerCategory BMCC = ribbon.Categories["AllItem"];
            for (int i = 0; i < BMCC.GetItemCount(); i++)
            {
                BarItem bItem = BMCC.GetItem(i);
                try
                {
                    if ((bItem.Name.ToString() != ""))
                    {
                        DataRow[] drs = ds.Tables[0].Select("FuncID='" + bItem.Name.ToString() + "'");
                        if (drs.Length == 0)
                        {
                            bItem.Enabled = false;
                            //bItem.Visibility = BarItemVisibility.Never;
                        }



                    }
                }
                catch (Exception)
                {

                }
            }

            //RibbonPageGroupItemLinkCollection collection = barButtonItem1.Links[0].Links as RibbonPageGroupItemLinkCollection;
            //RibbonPageGroup pageGroup = collection.PageGroup;

            //bool flag = false;
            //for (int i = 0; i < rpgPatientInfo.ItemLinks.Count; i++)
            //{
            //    if (rpgPatientInfo.ItemLinks[i].Visible)
            //    {
            //        flag = true;
            //        break;
            //    }
            // }
            //rpgPatientInfo.Visible = flag;


        }

        //-----------------------------------------------------------------------------
        private void OpenWindow(string ChildTypeString, string sDllName)
        {
            OpenWindow(ChildTypeString, sDllName, "");
        }

        private void OpenWindow(string ChildTypeString, string sDllName, string sPara)
        {
            OpenWindow(ChildTypeString, sDllName, sPara, null);
        }

        private void OpenWindow(string ChildTypeString, string sDllName, TierService.ObjectPara ObjPara)
        {
            OpenWindow(ChildTypeString, sDllName, "", ObjPara);
        }

        private void OpenWindow(string ChildTypeString, string sDllName, string sPara, TierService.ObjectPara ObjPara)
        {
            //if (!RegisterHelper.IsRegisted())
            //{
            //    XtraMessageBox.Show("您使用的软件没有注册，请注册!");
            //}
            frmTemplate myChild = null;
            if (!ContainMDIChild(ChildTypeString))
            {
                // Get current process assembly
                //Assembly assembly = Assembly.GetExecutingAssembly();                
                Assembly assembly = Assembly.Load(sDllName);

                // Create data type using type string
                Type typForm = assembly.GetType(ChildTypeString);

                // Create object using type's "InvokeMember" method
                Object obj = typForm.InvokeMember(
                    null,
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Public | BindingFlags.NonPublic |
                    BindingFlags.Instance | BindingFlags.CreateInstance,
                    null,
                    null,
                    null);

                //Set Ribon minimize
                IsRibonBarHide = false;
                ribbon.Minimized = true;
                iRobinHide.ImageIndex = 29;

                // Show child form 
                if (obj != null)
                {
                    myChild = obj as frmTemplate;
                    myChild.MdiParent = this;
                    //myChild.gQnaireType = QuestionnaireType;
                    myChild.Tag = sPara;
                    myChild.ObjPara = ObjPara;
                    myChild.StartPosition = FormStartPosition.CenterScreen;
                    myChild.gPara = sPara;
                    myChild.Height = 670;

                    WaitDialog.CreateWaitDialog("正在加载数据", "");
                    myChild.Show();
                    myChild.Focus();
                    WaitDialog.CloseWaitDialog();
                }
            }
        }


        private void GetDLLForm(string sDll, string sType)
        {
            GetDLLForm(sDll, sType, "GetInstance");
        }

        private void GetDLLForm(string sDll, string sType, string sFunc)
        {
            if (!RegisterHelper.IsRegisted())
            {
                XtraMessageBox.Show("您使用的软件没有注册，请注册!");
            }
            frmTemplate myChild = null;
            if (!ContainMDIChild(sType))
            {
                Assembly assembly = null;
                Type typForm = null;
                try
                {
                    assembly = Assembly.Load(sDll);  //加载dll文件
                }
                catch (Exception)
                {
                    MessageBox.Show("加载程序出错,缺少文件:" + sDll);
                    return;
                }

                if (assembly == null)
                {
                    MessageBox.Show("加载程序出错,缺少文件:" + sDll);
                    return;
                }
                try
                {
                    typForm = assembly.GetType(sType);  //获取类名，必须 命名空间+类名
                }
                catch (Exception)
                {
                    MessageBox.Show("加载窗体出错,程序文件'" + sDll + "'中，缺少窗体'" + sType + "'");
                    return;
                }

                if (typForm == null)
                {
                    MessageBox.Show("加载窗体出错,程序文件'" + sDll + "'中，缺少窗体'" + sType + "'");
                    return;
                }

                Object obj = Activator.CreateInstance(typForm);  //建立实例  
                MethodInfo meth = typForm.GetMethod(sFunc);  //获取方法

                //Set Ribon minimize
                IsRibonBarHide = false;
                ribbon.Minimized = true;
                iRobinHide.ImageIndex = 29;

                // Show child form 
                if (obj != null)
                {
                    myChild = obj as frmTemplate;
                    myChild.MdiParent = this;
                    myChild.StartPosition = FormStartPosition.CenterScreen;
                    myChild.Height = 670;
                    WaitDialog.CreateWaitDialog("正在加载数据", "");

                    meth.Invoke(obj, new string[] { sType }); ;  //Invoke调用方法

                    WaitDialog.CloseWaitDialog();
                }
            }
        }
        //-----------------------------------------------------------------------------

        /// <summary>
        /// Open child window
        /// </summary>
        /// <param name="ChildTypeString"></param>
        /// 

        /// <summary>
        /// /---------
        /// </summary>
        /// <param name="ChildTypeString"></param>

        private void OpenWindowE(string ChildTypeString)
        {
            string tag = ChildTypeString;
            OpenWindowE(ChildTypeString, tag);
        }

        private void OpenWindowE(string ChildTypeString, string tag)
        {
            //if (!TierService.RegisterHelper.IsRegisted())
            //{
            //    XtraMessageBox.Show("您使用的软件没有注册，请注册!");
            //}
            TierService.frmTemplate myChild = null;
            if (!ContainMDIChild(ChildTypeString))
            {
                // Get current process assembly
                Assembly assembly = Assembly.GetExecutingAssembly();

                // Create data type using type string
                Type typForm = assembly.GetType(ChildTypeString);

                // Create object using type's "InvokeMember" method
                Object obj = typForm.InvokeMember(
                    null,
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Public | BindingFlags.NonPublic |
                    BindingFlags.Instance | BindingFlags.CreateInstance,
                    null,
                    null,
                    null);

                //Set Ribon minimize
                IsRibonBarHide = false;
                ribbon.Minimized = true;
                iRobinHide.ImageIndex = 29;

                // Show child form 
                if (obj != null)
                {
                    myChild = obj as TierService.frmTemplate;
                    myChild.MdiParent = this;
                    //myChild.gFuncType = QuestionnaireType;
                    myChild.Tag = tag;
                    myChild.StartPosition = FormStartPosition.CenterScreen;

                    TierService.WaitDialog.CreateWaitDialog("正在加载数据", "");
                    myChild.Show();
                    myChild.Focus();
                    TierService.WaitDialog.CloseWaitDialog();
                }
            }
        }

        /// <summary>
        /// Search mdi child form by specific type string
        /// </summary>
        /// <param name="ChildTypeString"></param>
        /// <returns></returns>
        private bool ContainMDIChild(string ChildTypeString)
        {


            TierService.frmTemplate myMDIChild = null;
            foreach (frmTemplate f in this.MdiChildren)
            {
                if (f.GetType().ToString() == ChildTypeString)
                {
                    // found it 
                    myMDIChild = f;
                    break;
                }
            }

            // Show the exist form
            if (myMDIChild != null)
            {
                if (Tag == "Product")
                    myMDIChild.gProductType = Utility.ProductType.Product;

                switch (myMDIChild.gProductType)
                {
                    case Utility.ProductType.Product:
                        myMDIChild.Close();
                        return false;
                    case Utility.ProductType.MProduct:
                        myMDIChild.Close();
                        return false;
                    default:
                        myMDIChild.TopMost = true;
                        myMDIChild.StartPosition = FormStartPosition.CenterScreen;
                        myMDIChild.Show();
                        myMDIChild.Focus();
                        return true;
                }
            }
            else
                return false;
        }

        private void frmBRS_Load(object sender, EventArgs e)
        {
            foreach (DevExpress.Skins.SkinContainer skin in DevExpress.Skins.SkinManager.Default.Skins)
            {
                BarCheckItem item = ribbon.Items.CreateCheckItem(skin.SkinName, false);
                item.Tag = skin.SkinName;
                item.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(OnPaintStyleClick);
                iPaintStyle.ItemLinks.Add(item);
            }

            defaultLookAndFeel1.LookAndFeel.SetSkinStyle("Office 2007 Blue");
            //SetBarButtonItemImage();

            ribbon.SelectedPage = ribbon.Pages[0];
        }




        void OnPaintStyleClick(object sender, ItemClickEventArgs e)
        {
            defaultLookAndFeel1.LookAndFeel.SetSkinStyle(e.Item.Name.ToString());
        }

        private void iPaintStyle_Popup(object sender, System.EventArgs e)
        {
            foreach (BarItemLink link in iPaintStyle.ItemLinks)
                ((BarCheckItem)link.Item).Checked = link.Item.Caption == defaultLookAndFeel1.LookAndFeel.ActiveSkinName;
        }

        #region SkinGallery
        void InitSkinGallery()
        {
            SimpleButton imageButton = new SimpleButton();
            foreach (SkinContainer cnt in SkinManager.Default.Skins)
            {
                imageButton.LookAndFeel.SetSkinStyle(cnt.SkinName);
                GalleryItem gItem = new GalleryItem();
                int groupIndex = 0;
                if (cnt.SkinName.Contains("Office")) groupIndex = 1;
                //if (DevExpress.DXperience.Demos.LookAndFeelMenu.IsBonusSkin(cnt.SkinName)) groupIndex = 2;
                rgbiSkins.Gallery.Groups[groupIndex].Items.Add(gItem);
                gItem.Caption = cnt.SkinName;

                gItem.Image = GetSkinImage(imageButton, 32, 17, 2);
                gItem.HoverImage = GetSkinImage(imageButton, 70, 36, 5);
                gItem.Caption = cnt.SkinName;
                gItem.Hint = cnt.SkinName;
            }
            rgbiSkins.Gallery.Groups[1].Visible = false;
            rgbiSkins.Gallery.Groups[2].Visible = false;
        }
        Bitmap GetSkinImage(SimpleButton button, int width, int height, int indent)
        {
            Bitmap image = new Bitmap(width, height);
            using (Graphics g = Graphics.FromImage(image))
            {
                StyleObjectInfoArgs info = new StyleObjectInfoArgs(new GraphicsCache(g));
                info.Bounds = new Rectangle(0, 0, width, height);
                button.LookAndFeel.Painter.GroupPanel.DrawObject(info);
                button.LookAndFeel.Painter.Border.DrawObject(info);
                info.Bounds = new Rectangle(indent, indent, width - indent * 2, height - indent * 2);
                button.LookAndFeel.Painter.Button.DrawObject(info);
            }
            return image;
        }
        private void rgbiSkins_Gallery_ItemClick(object sender, DevExpress.XtraBars.Ribbon.GalleryItemClickEventArgs e)
        {
            DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(e.Item.Caption);
        }

        private void rgbiSkins_Gallery_InitDropDownGallery(object sender, DevExpress.XtraBars.Ribbon.InplaceGalleryEventArgs e)
        {
            e.PopupGallery.CreateFrom(rgbiSkins.Gallery);
            e.PopupGallery.AllowFilter = false;
            e.PopupGallery.ShowItemText = true;
            e.PopupGallery.ShowGroupCaption = true;
            e.PopupGallery.AllowHoverImages = false;
            foreach (GalleryItemGroup galleryGroup in e.PopupGallery.Groups)
                foreach (GalleryItem item in galleryGroup.Items)
                    item.Image = item.HoverImage;
            e.PopupGallery.ColumnCount = 2;
            e.PopupGallery.ImageSize = new Size(70, 36);
        }
        #endregion

        private void iRobinHide_ItemClick(object sender, ItemClickEventArgs e)
        {
            IsRibonBarHide = !IsRibonBarHide;
            if (IsRibonBarHide)
            {
                iRobinHide.ImageIndex = 30;
                ribbon.Minimized = true;
                if (ActiveMdiChild != null)
                {
                    this.ActiveMdiChild.Location = new Point(5, 5);
                }
            }
            else
            {
                iRobinHide.ImageIndex = 29;
                ribbon.Minimized = false;
                if (ActiveMdiChild != null)
                {
                    this.ActiveMdiChild.Location = new Point(5, 5);
                }
            }

        }


        #region OpenForm
        private void iUser_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Admin.frmUser).ToString(), e.Item.Name.ToString());

            OpenWindow(typeof(BasisMgr.frmUser).ToString(), DLL_BasisMgr, e.Item.Name.ToString());
        }

        private void iDepartment_ItemClick(object sender, ItemClickEventArgs e)
        {
            OpenWindow(typeof(BasisMgr.frmDepartment).ToString(), DLL_BasisMgr, e.Item.Name.ToString());
        }

        private void iRole_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Admin.frmRole).ToString(), e.Item.Name.ToString());

            OpenWindow(typeof(BasisMgr.frmRole).ToString(), DLL_BasisMgr, e.Item.Name.ToString());
        }

        private void iPriv_ItemClick(object sender, ItemClickEventArgs e)
        {
            OpenWindow(typeof(BasisMgr.frmFuncControls).ToString(), DLL_BasisMgr, e.Item.Name.ToString());
        }

        private void iCode_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Admin.frmDataDictionary).ToString(), e.Item.Name.ToString());

            OpenWindow(typeof(BasisMgr.frmDataDictionary).ToString(), DLL_BasisMgr, e.Item.Name.ToString());
        }

        private void iMmxg_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Admin.frmPassword).ToString(), e.Item.Name.ToString());

            OpenWindow(typeof(BasisMgr.frmPassword).ToString(), DLL_BasisMgr, e.Item.Name.ToString());
        }

        private void iDataBackup_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Admin.frmDataBackup).ToString(), e.Item.Name.ToString());

            OpenWindow(typeof(BasisMgr.frmDataBackup).ToString(), DLL_BasisMgr, e.Item.Name.ToString());
        }

        private void iSection_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Admin.frmSection).ToString(), e.Item.Name.ToString());
            OpenWindow(typeof(BasisMgr.frmSection).ToString(), DLL_BasisMgr, e.Item.Name.ToString());
        }

        #endregion

        private void SetBarButtonItemImage()
        {
            string imagePath = TierService.Utility.imageFilePath;
        }

        private void iQuit_ItemClick(object sender, ItemClickEventArgs e)
        {
            Application.Exit();
        }

        private void iCustomer_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CustomerInfo.frmCustomer).ToString());
            OpenWindow(typeof(OrderMgr.CustomerInfo.frmCustomer).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iSupplier_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CustomerInfo.frmSupplier).ToString());
            OpenWindow(typeof(OrderMgr.CustomerInfo.frmSupplier).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBuy_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBuys).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuys).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBuyToStock_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBuyToStock).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyToStock).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }


        private void iSale_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmSales).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmSales).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iSaleShip_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmSaleShip).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmSaleShip).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iReceipt_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmSaleInvoice).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmSaleInvoice).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iSaleAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmSaleAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmSaleAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iTransfer_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmTransfer).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmTransfer).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iStockTake_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmStockTake).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmStockTake).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iWastage_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmWastage).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmWastage).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }


        private void iBuyAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBuyAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBuySearch_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBuyOrderSearch).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyOrderSearch).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBuySearchByProduct_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBuySearchByProduct).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuySearchByProduct).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iRptStock_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Rpt.frmRptStock).ToString());
            OpenWindow(typeof(OrderMgr.Rpt.frmRptStock).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iRptStockDetail_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Rpt.frmRptStockDetail).ToString());
            OpenWindow(typeof(OrderMgr.Rpt.frmRptStockDetail).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBuyCancelStock_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBuyCancelStock).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyCancelStock).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iSaleCancel_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmSaleCancel).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmSaleCancel).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iRptSale_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Rpt.frmRptSale).ToString());
            OpenWindow(typeof(OrderMgr.Rpt.frmRptSale).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iRptSaleProduct_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Rpt.frmRptSaleProduct).ToString());
            OpenWindow(typeof(OrderMgr.Rpt.frmRptSaleProduct).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iRptSaleProductD_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Rpt.frmRptSaleProductD).ToString());
            OpenWindow(typeof(OrderMgr.Rpt.frmRptSaleProductD).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }


        private void iOrderShipSetup_ItemClick(object sender, ItemClickEventArgs e)
        {
            //CustomDesignForm fForm = new CustomDesignForm();
            DevExpress.XtraReports.UI.XtraReport fReport = new DevExpress.XtraReports.UI.XtraReport();
            fReport.ShowRibbonDesigner();
        }


        private void iRegion_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Admin.frmRegion).ToString());
            OpenWindow(typeof(BasisMgr.frmSection).ToString(), DLL_BasisMgr, e.Item.Name.ToString());

        }

        private void iStockAlert_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(SysSetting.frmProductList).ToString());

            OpenWindow(typeof(OrderMgr.SysSetting.frmProductList).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iPayApp_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CodePortal.OrderInfo.frmBuyPayApp).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyPayApp).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iPayAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CodePortal.OrderInfo.frmBuyPayAudit).ToString());

            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyPayAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iPayment_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CodePortal.OrderInfo.frmBuyPayment).ToString());

            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyPayment).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iInvoiceApp_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CodePortal.OrderInfo.frmBuyInvoiceApp).ToString());

            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyInvoiceApp).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iInvoiceAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CodePortal.OrderInfo.frmBuyInvoiceAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyInvoiceAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBuyToStockAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CodePortal.OrderInfo.frmBuyToStockAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBuyToStockAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iSaleShipAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmSaleShipAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmSaleShipAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iReturnFee_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(CodePortal.OrderInfo.frmSaleReturnFee).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmSaleReturnFee).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iTransferAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmTransferAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmTransferAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iStockTakeAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmStockTakeAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmStockTakeAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iWastageAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmWastageAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmWastageAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iRptSaleAnalysis_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(Rpt.).ToString());
            OpenWindow(typeof(OrderMgr.Rpt.frmRptSaleAnalysis).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBorrow_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBorrow).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBorrow).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBorrowAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBorrowAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBorrowAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void ifrmBorrowToStock_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBorrowToStock).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBorrowToStock).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBorrowToStockAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBorrowToStockAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBorrowToStockAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iBorrowSendBack_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBorrowSendBack).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBorrowSendBack).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iiBorrowSendBackAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmBorrowSendBackAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmBorrowSendBackAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iLoan_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmLoan).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmLoan).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iLoanAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmLoanAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmLoanAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iLoanStock_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmLoanStock).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmLoanStock).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iLoanStockAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmLoanStockAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmLoanStockAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iLoanReturnBack_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmLoanReturnBack).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmLoanReturnBack).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iLoanReturnBackAudit_ItemClick(object sender, ItemClickEventArgs e)
        {
            //OpenWindowE(typeof(OrderInfo.frmLoanReturnBackAudit).ToString());
            OpenWindow(typeof(OrderMgr.OrderInfo.frmLoanReturnBackAudit).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iProduct_ItemClick(object sender, ItemClickEventArgs e)
        {
            OpenWindow(typeof(OrderMgr.SysSetting.frmProduct).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

        private void iRptSaleReturnFee_ItemClick(object sender, ItemClickEventArgs e)
        {
            OpenWindow(typeof(OrderMgr.Rpt.frmRptNeedReturnFeeDetail).ToString(), DLL_OrderMgr, e.Item.Name.ToString());
        }

    }
}

